package com.example.configclient;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.client.ConfigClientProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.core.env.Environment;

@SpringBootApplication
@EnableEurekaClient
@RefreshScope
public class ConfigClientApplication implements CommandLineRunner {
	private static Log logger = LogFactory.getLog(ConfigClientApplication.class);

	@Value("${spring.datasource.username}")
	private String password="test";
/*	@Value("${info.bar}")
	private String inforBar="test";*/
	@Autowired
	private ConfigClientProperties config;
	@Autowired
	private Environment environment;
	public static void main(String[] args) {
		SpringApplication.run(ConfigClientApplication.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		logger.info("Config Server URI: " + this.config.getUri());
		logger.info("And info.bar: " + this.environment.getProperty("system.bar"));
		System.out.printf(password);
	}

}
